<?php
$operationList = Blyn::app()->getActiveApp()->getOperationList();
$model = new BWXMenuFormModel();
$wxControl = new BUIWXControl();
//$model->applicationId = 'wxd33a8d04590d6e58';
//$model->spaceUrl = yii::app()->request->hostInfo . $wxControl->getLinkUrl();
if (isset($_POST['BWXMenuFormModel'])) {
    $model->attributes = $_POST['BWXMenuFormModel'];
}
$showMenuControl = new BUIControl();
$activeOperation = Blyn::app()->getActiveOperation();
$Appid = NULL;
$AppSecret = NULL;
if(Blyn::app()->getActiveSpace()->getAttribute('wechat_appid'))
    $Appid = Blyn::app()->getActiveSpace()->getAttribute('wechat_appid')->getValue();
if(Blyn::app()->getActiveSpace()->getAttribute('wechat_appsecret'))
    $AppSecret = Blyn::app()->getActiveSpace()->getAttribute('wechat_appsecret')->getValue();
?>
<?php echo CHtml::beginForm(); ?>
<div class='well' style="min-height: 150px;">
    <div style="display: none;">
        <form class="form-horizontal" style="display:none;">
            <!--        <div class="control-group">        
                        <label class="control-label" for="inputAppId"><?php // echo CHtml::activeLabel($model, 'applicationId');  ?></label>
                        <div class="controls">
            <?php // echo CHtml::activeTextField($model, 'applicationId', array('id' => 'inputAppId', 'readonly' => 'true')) ?>         
                        </div>
                    </div>
                    <div class="control-group">        
                        <label class="control-label"><?php // echo CHtml::activeLabel($model, 'spaceUrl');  ?></label>
                        <div class="controls">
            <?php // echo CHtml::activeTextField($model, 'spaceUrl', array('readonly' => 'readonly', 'class' => 'span9')) ?>         
                        </div>
                    </div>-->
            <div class="control-group">        
                <label class="control-label"><?php echo CHtml::activeLabel($model, 'operationId'); ?></label>
                <div class="controls">
                    <?php echo CHtml::activeDropDownList($model, 'operationId', $operationList) ?>         
                </div>
            </div>   
        </form>
    </div>
    <div>
        <ul style="margin-left: 32px;">
            <li style="font-weight: bold;list-style-type:none;">微信应用AppId：<?php echo CHtml::activeTextField($model, 'applicationId', array('required' => 'required', 'id' => 'AppId', 'placeholder'=>'AppId','style'=>'min-width: 250px;', 'value' =>$Appid,'onkeyup'=>"this.value=this.value.replace(' ','')")) ?></li>
        </ul>
        <ul style="margin-left: 0px;margin-bottom: 0px;">
            <li style="font-weight: bold;list-style-type:none;">微信应用AppSecret：<?php echo CHtml::activeTextField($model, 'appSecret', array('required' => 'required', 'id' => 'AppSecret', 'placeholder'=>'AppSecret','style'=>'min-width: 250px;','value' =>$AppSecret,'onkeyup'=>"this.value=this.value.replace(' ','')")) ?></li>
        </ul>
         <label class="control-label">
             <?php 
               echo $control->getAjaxLink(array('name' => '如何获取AppId以及AppSecret', 'id' => 'getHelp'), array(
             'htmlOptions' => array()
              ));
             ?>
         </label>
    </div>
    <div style="float: left;">
        <?php echo $showMenuControl->getAjaxLink('配置微信信息', array('htmlOptions' => array('class' => 'btn'))); ?>
        <?php echo $showMenuControl->getAjaxLink('Show Menu Designer', array('htmlOptions' => array('class' => 'btn'))); ?>
    </div>
   <div style="float: right;">
       <!--<button type="button" class="btn btn-primary">微信企业号</button>-->
       <?php
          echo $control->getAjaxLink(array('name' => '微信企业号', 'id' => 'WeChatQy'), array(
             'htmlOptions' => array(
                 'class' => 'btn btn-primary')
              ));
       ?>
   </div>
</div>
<div>
    <?php $showMenuControl->render(); ?>
</div>

<?php echo CHtml::endForm(); ?>